package cn.tedu.basic;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

// 测试     反 射--执行有注解的方法
public class Test4_UseReflect {
    public static void main(String[] args) throws IllegalAccessException, InstantiationException, InvocationTargetException {
        Class<Person> c = Person.class;
        Method[] m = c.getDeclaredMethods();
        for (Method me : m){
            Person.Controller con = me.getAnnotation(Person.Controller.class);
            if (con!=null){
                Person p = c.newInstance();
                me.invoke(p);
            }

        }


    }
}
